<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>设置我的资料</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../layui/2.3.0/css/layui.css" media="all">
  <link rel="stylesheet" href="../layui/2.3.0/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
 <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">设置我的资料</div>
          <div class="layui-card-body" pad15>
            <form  class="layui-form"  id="postForm" action="." method="post">
            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">我的角色</label>
                <div class="layui-input-inline">
                  <select name="user.meta" lay-verify="" value="${user.meta}">
                    <option value="539609" >平台管理员</option>
                    <option value="539608"  >供货商管理员</option>
                    <option value="539607" >物流公司管理员</option>
                    <option value="539590" >司机</option>
                  </select> 
                </div>
                <div class="layui-form-mid layui-word-aux">当前角色不可更改为其它角色</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.username" value="${user.username}" readonly class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.fullname" value="${user.fullname}" lay-verify="nickname" autocomplete="off" placeholder="请输入昵称" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.surname" value="${user.surname}" lay-verify="" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
                </div>
              </div>
               <div class="layui-form-item">
                <label class="layui-form-label">生日</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.birth" id="birth" value="${user.birth}" lay-verify="birth" autocomplete="off" placeholder="请输入生日" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block radioGroup" >
                  <input type="radio" <s:if test='user.gender==1'>checked</s:if> name="user.gender" value="1" title="男">
                  <input type="radio"  <s:if test='user.gender==2'>checked</s:if> name="user.gender" value="2" title="女" >
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">头像</label>
                <div class="layui-input-inline">
                <div class="layui-input-inline layui-btn-container" style="width: auto;">
                  <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                    <i class="layui-icon">&#xe67c;</i>上传图片
                  </button>
                </div>
                  <div class="layui-upload-list" >
                <img class="layui-upload-img" id="avatar" style="width:100px;height:100px;"src1="../module/User-getAvatar.action" id="test-upload-normal-img">
              </div>
               	
                </div>
                
             </div>
              <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.mobile" value="${user.mobile}" lay-verify="phone" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.email" value="${user.email}" lay-verify="email" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">QQ或微信</label>
                <div class="layui-input-inline">
                  <input type="text" name="user.imcode" value="${user.imcode}" lay-verify="" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                  <textarea name="user.mark" placeholder="请输入内容" value="" class="layui-textarea">${user.mark}</textarea>
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit id="modifyBtn" lay-filter="setmyinfo">确认修改</button>
                </div>
              </div>
            </div>
            </form>
          </div>
        </div>
      </div>
    </div>
</div>
<script th:src="@{./../layui/2.3.0/layui.js}"></script>
  <script>
  layui.config({
    base: '../layui/2.3.0/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  })..use(['form','laydate','upload'],function(){
  
	  var form = layui.form
	  ,layer = layui.layer
	  ,laydate = layui.laydate,
	  upload=layui.upload,
	  $=layui.jquery;
	   laydate.render({
	    elem: '#birth'
	  });
	  var src=$("#avatar").attr("src1");
	  $("#avatar").attr("src",src);
	  var uploadBizlicense = upload.render({
		    elem: '#LAY_avatarUpload'
		    ,url: '../module/User-uploadAvatar.action'
		    ,before: function(obj){
		      
		    }
		    ,done: function(res){
		    $("#avatar").attr("src",$("#avatar").attr("src1")+"?_="+new Date().getTime());
		      //如果上传失败
		      if(!res.success){
		    	  
		      }else{
		    	  layer.msg('上传成功');
		    	  
		      }
		      
		    }
		    ,error: function(){
		    	 return layer.msg('上传失败');
		    }
		  });
		  
	  $("#modifyBtn").click(function(){
		  $("#postForm").submit();
	  });
	    form.on('submit(setmyinfo)', function(data){
		  console.log(data);
		    return true;
		});
	  $(".radioGroup").each(function(){
		  var v=$(this).attr("option");
		  $(this).find("[value="+v+"]").attr("checked",true);
	  });
	 });
  </script>
</body>
</html>


